<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>仓管理</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/own.css" />
		<link rel="stylesheet" href="../css/iconfont.css" />
		<script type="text/javascript" src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<style type="text/css">
			.mui-content-padded div {
				font-size: 0.6rem;
				padding: 0.2rem 0.8rem;
				border-radius: 0.2rem;
				border: solid 0.5px #D6D6D6;
				font-weight: 600;
			}

			.zt_c {
				height: 0.8rem;
				display: inline-block;
				background: #007aff;
				color: #ffffff;
				font-size: 0.5rem;
				padding: 0 0.2rem;
				border-radius: 0.2rem;
				margin-left: 0.3rem;
				line-height: 0.9rem;
			}

			.mui-table-view-cell.mui-active {
				background-color: #fff;
			}
		</style>
	</head>

	<body style="background: #FFFFFF;font-size: 0.8rem;">
		<header class="mui-bar own-mui-bar-nav own-main-background-color ">
			<h1 class="mui-title">仓管理</h1>
			<a class="mui-icon mui-icon-plusempty mui-icon-right-nav mui-pull-right" style="font-size: 1.6rem;line-height: 1rem;margin-right: 0.2rem;display: none;"id="add"></a>
		</header>
		<div class="mui-content" style="background: #FFFFFF;">

			<ul class="mui-table-view" id="ul_list">
				<!-- <li class="mui-table-view-cell" onclick="gotoSumPage()"><span style="line-height: 0.8rem;">沥青心墙 39层</span><span
					 class="zt_c" id="zt_span0" style="background:#00963C">已开仓</span>
					<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;">
						<div class="mui-pull-left">工程编号：<span>B-BE</span></div>
						<div class="mui-pull-right">高程：<span>1435.56</span></div>
					</div>
					<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;">
						<div class="mui-pull-left">开仓时间：<span>06-08 19:40</span></div>
					</div>
					<div class="mui-content-padded" id="gc_div0">
						<div class="mui-inline mui-pull-left" onclick="setkgc('1','B-BE','39','0')">开仓</div>
						<div class="mui-inline mui-pull-left" style="margin-left: 1.5rem;" onclick="setkgc('0','B-BE','39','0')">暂停</div>
						<div class="mui-inline mui-pull-right" style="margin-left: 1.5rem;" onclick="setsyjc('-1','B-BE','39','0')">试验</div>
						<div class="mui-inline mui-pull-right" onclick="setkgc('-1','B-BE','39','0')">关仓</div>
						
					</div>
				</li> -->
			</ul>

		</div>

	</body>
	<script>
		mui.init();

		var indexview = null;

		var dycOde = null;

		mui.plusReady(function() {

			indexview = plus.webview.currentWebview();

			dycOde = indexview.data;

			if (dycOde == 'B') {

				$('#add').show();

				document.getElementById('add').addEventListener('tap', function() {
					gotoSumPage('house_info.html?' + localStorage.getItem('node'));
				})
				ajaxinfo('');
			} else {
				ajaxinfo(dycOde);
			}
		});

		function ajaxinfo(code) {
			mpms_ajax({
				node: localStorage.getItem('node'),
				uid: code
			}, 'getPieceList', function(data) {
				if (data.list.length > 0) {
					$('#ul_list').empty();
					for (let i = 0; i < data.list.length; i++) {
						setItems(data.list[i], i);
					}
				}
			})
		}

		function setItems(info, i) {
			var htmls = '';
			htmls += '<li class="mui-table-view-cell" onclick="gotoSumPage()">';
			htmls += '<span style="line-height: 0.8rem;">' + info.name + ' ' + info.layer + '层</span>';
			if (info.status == '-1') {
				htmls += '<span class="zt_c" id="zt_span' + i + '" style="background: #2E3E51">已关仓</span>'
			} else if (info.status == '0') {
				htmls += '<span class="zt_c" id="zt_span' + i + '" style="background:#FFB800">已暂停</span>'
			} else if (info.status == '1') {
				htmls += '<span class="zt_c" id="zt_span' + i + '" style="background:#00963C">已开仓</span>'
			} else {
				htmls += '<span class="zt_c" id="zt_span' + i + '" style="background:#ffffff"></span>'
			}
			htmls += '<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;">';
			htmls += '<div class="mui-pull-left">工程编号：<span >' + info.uid + '</span></div>';
			htmls += '<div class="mui-pull-right">高程：<span >' + info.b_high + '</span></div></div>';
			htmls += '<div class="zs_content_bg mui-clearfix" style="font-size: 0.6rem;margin-top: 0.3rem;">';
			if (!isNull(info.open_time)) {
				htmls += '<div class="mui-pull-left">开仓时间：<span >' + info.open_time + '</span></div>';
				if (!isNull(info.close_time)) {
					htmls += '<div class="mui-pull-right">关仓时间：<span >' + info.close_time + '</span></div>';
				}
			}

			if (info.status != '-1') {
				htmls += '</div><div class="mui-content-padded" id="gc_div' + i +'">  <div class="mui-inline mui-pull-left"  onclick="setkgc(\'' + '1' + '\',\'' + info.uid + '\',\'' + info.layer +'\',\'' + i + '\')">开仓</div>';
				htmls += ' <div class="mui-inline mui-pull-left" style="margin-left: 1.2rem;" onclick="setkgc(\'' + '0' + '\',\'' +info.uid + '\',\'' + info.layer + '\',\'' + i + '\')">暂停</div>';
				htmls += '<div class="mui-inline mui-pull-right" style="margin-left: 1.2rem;" onclick="setsyjc(\'' + info.syid + '\',\'' + info.uid + '\',\'' + info.layer +'\',\'' + i + '\')">试验</div>';
				htmls += '<div class="mui-inline mui-pull-right" onclick="setkgc(\'' + '-1' + '\',\'' + info.uid + '\',\'' + info.layer +'\',\'' + i + '\')">关仓</div>';
	
			}
			htmls += '</div></li>'
			$('#ul_list').append(htmls);


		}

		function setkgc(a, b, c, i) {
			var params = {
				'node': localStorage.getItem('node'), //节点编号
				'uid': b, //单元工程编号
				'layer': c, //层号
				'act': a //执行状态
			};
			mpms_ajax(params, 'pieceAct', function(data) {
				var str = null;

				if (a == '-1') {
					str = '已关仓'
					$('#zt_span' + i).css('background', '#2E3E51');
					$('#gc_div' + i).hide();

				} else if (a == '0') {
					str = '已暂停'
					$('#zt_span' + i).css('background', '#FFB800');
				} else if (a == '1') {
					str = '已开仓'
					$('#zt_span' + i).css('background', '#00963C');
				}
				$('#zt_span' + i).text(str);

				mui.toast('操作成功!');

			})

		}
		/* 试验检测逻辑 */
		function setsyjc(syid,uid,layer,i){
			 gotoSumPage('experiment.html?'+syid+'?'+uid+'?'+layer+'?'+i );
		}
	</script>

</html>
